import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import eslint from '@rollup/plugin-eslint'

/**
 * @type {import('vite').UserConfig}
 */
export default {
  plugins: [
    vue(),
    {
      ...eslint({ include: '**/*.+(vue|js|jsx|ts|tsx)' }),
      enforce: 'pre',
      apply: 'build',
    },
  ],
  optimizeDeps: {
    include: ['@ant-design/icons-vue', 'ant-design-vue', 'axios'],
    included: ['lodash-es'],
  },
  resolve: {
    alias: {
      '/@/': resolve(__dirname, '/src'),
    },
  },
  server: {
    host: 'localhost',
    port: 3000,
    https: false,
    open: false,
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
    cors: true,
  },
}
